/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kotionokyurievna.gmail.com.genproj.logic;

/**
 *
 * @author Kateryna_Reznik
 */
public class Apple extends Fruit implements Comparable<Apple>{

    private int size; // size of apple >= 0

    public Apple(){
        setSize(0);
        setType("Apple");
    }
    
    public Apple ( int appleSize ){
        setSize(appleSize);
        setType("Apple");
    }
    
    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        if ( size > 0 ){
            this.size = size;
        }
        else{
            size = 0;
        }
    }
    
     public boolean equals( Object obj ){
        
        if ( super.equals(obj) && getClass() == obj.getClass() ){
            Apple other = (Apple) obj;
            return size == other.size;
	}
        return false;
    }
    
    public String toString(){
        return super.toString() + " [ size = "  + getSize() + "]";
    }
    
    @Override
    public int compareTo(Apple o) {
        if ( size == o.size ){
            return 0;
        }
        else{
           if ( size > o.size ){
                return 1;
           } 
        }
        return -1;
    }
    
}
